<extend name="Public/base"/>

<!-- 子導航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>

<block name="body">
    <!-- 標題 -->
    <div class="main-title">
        <h2>
            文檔列表({$_total}) [
            <volist name="rightNav" id="nav">
                <a href="{:U('article/index','cate_id='.$nav['id'])}">{$nav.title}</a>
                <if condition="count($rightNav) gt $i"><i class="ca"></i></if>
            </volist>
            <present name="article">：<a href="{:U('article/index','cate_id='.$cate_id.'&pid='.$article['id'])}">{$article.title}</a></present>
            ]
            <eq name="allow" value="0">（該分類不允許發布內容）</eq>
        </h2>
    </div>

    <!-- 按鈕工具欄 -->
    <div class="cf">
        <div class="fl">
            <div class="btn-group">
                <gt name="allow" value="0">
                <button class="btn document_add" <if condition="count($model) eq 1">url="{:U('article/add',array('cate_id'=>$cate_id,'pid'=>I('pid',0),'model_id'=>$model[0]))}"</if>>新 增
                    <if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
                </button>
                <if condition="count($model) gt 1">
                    <ul class="dropdown nav-list">
                        <volist name="model" id="vo">
                            <li><a href="{:U('article/add',array('cate_id'=>$cate_id,'model_id'=>$vo,'pid'=>I('pid',0)))}">{$vo|get_document_model='title'}</a></li>
                        </volist>
                    </ul>
                </if>
                <else/>
                <button class="btn disabled" >新 增
                    <if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
                </button>
                </gt>
            </div>
            <button class="btn ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>1))}">啟 用</button>
            <button class="btn ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>0))}">禁 用</button>
            <input type="hidden" class="hide-data" name="cate_id" value="{$cate_id}"/>
            <input type="hidden" class="hide-data" name="pid" value="{$pid}"/>
            <button class="btn ajax-post confirm" target-form="ids" url="{:U("Article/setStatus",array("status"=>-1))}">刪 除</button>
            <!-- <button class="btn document_add" url="{:U('article/batchOperate',array('cate_id'=>$cate_id,'pid'=>I('pid',0)))}">導入</button> -->
            <button class="btn list_sort" url="{:U('sort',array('cate_id'=>$cate_id,'pid'=>I('pid',0)),'')}">排序</button>
        </div>

        <!-- 高級搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
             <if condition="$cate_id=='45'">
                    <div class="drop-down">
                    <span id="sch-sort-txt" class="sort-txt" >所有</span>
                    <i class="arrow arrow-down"></i>
                    <ul id="sub-sch-menu" class="nav-list hidden">
                        <li><a href="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id,false)}" value="">所有</a></li>
                        <volist name="ptypes" id="datas">
                            <li><a href="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id.'&types='.$datas['id'])}" value="">{$datas['tname']}</a></li>
                        </volist>
                    </ul>
                </div>
                    <else/>
                <div class="drop-down">
                    <span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_title($status) eq ''">所有<else/>{:get_status_title($status)}</if></span>
                    <i class="arrow arrow-down"></i>
                    <ul id="sub-sch-menu" class="nav-list hidden">
                        <li><a href="javascript:;" value="">所有</a></li>
                        <li><a href="javascript:;" value="1">正常</a></li>
                        <li><a href="javascript:;" value="0">禁用</a></li>
                        <li><a href="javascript:;" value="2">待審核</a></li>
                    </ul>
                </div>
                   </if>
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="請輸入標題文檔">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id,false)}"><i class="btn-search"></i></a>
            </div>
            <div class="btn-group-click adv-sch-pannel fl">
                <button class="btn">高 級<i class="btn-arrowdown"></i></button>
                <div class="dropdown cf">
                    <div class="row">
                        <label>更新時間：</label>
                        <input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始時間" /> -
                        <input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="結束時間" />
                    </div>
                    <div class="row">
                        <label>創建者：</label>
                        <input type="text" name="nickname" class="text input-2x" value="" placeholder="請輸入用戶名">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 數據表格 -->
    <div class="data-table">
        <table>
            <!-- 表頭 -->
            <thead>
                <tr>
                    <th class="row-selected row-selected">
                        <input class="check-all" type="checkbox">
                    </th>
         
       
            <th>編號</th>
            <th>標題</th>
             <th>分類</th>
              <th>屬性</th>
           
            <th>最後更新時間</th>
            <th>操作</th>
            </tr>
            </thead>

            <!-- 列表 -->
            <tbody>
            <volist name="list" id="data">
                <tr>
                    <td><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
                <td>{$data['id']}</td>
                <td><a href="{:U('Article/edit?cate_id='.$data['category_id'].'&id='.$data['id'])}">{$data.title}</a></td>
                          <td>{$data['types']|get_type=tname}</td>     
                 <td>{$data['attribute']|get_att=aname}</td>
                       
                 <td>{$data['update_time']|date="y-m-d",###}</td>
                 <td><a href="{:U('Article/setStatus?status=-1&ids='.$data['id'])}" class="confirm ajax-get">刪除</a></td>
                </tr>
            </volist>
            </tbody>
        </table>
    </div>
    <!-- 分頁 -->
    <div class="page">
        {$_page}
    </div>
</div>

</block>
<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var status = $("#sch-sort-txt").attr("data");
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (status != '') {
                    query += 'status=' + status + "&" + query;
                }
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });

            /* 狀態搜索子菜單 */
            $(".search-form").find(".drop-down").hover(function () {
                $("#sub-sch-menu").removeClass("hidden");
            }, function () {
                $("#sub-sch-menu").addClass("hidden");
            });
            $("#sub-sch-menu li").find("a").each(function () {
                $(this).click(function () {
                    var text = $(this).text();
                    $("#sch-sort-txt").text(text).attr("data", $(this).attr("value"));
                    $("#sub-sch-menu").addClass("hidden");
                })
            });

            //只有壹個模型時，點擊新增
            $('.document_add').click(function () {
                var url = $(this).attr('url');
                if (url != undefined && url != '') {
                    window.location.href = url;
                }
            });

            //點擊排序
            $('.list_sort').click(function () {
                var url = $(this).attr('url');
                var ids = $('.ids:checked');
                var param = '';
                if (ids.length > 0) {
                    var str = new Array();
                    ids.each(function () {
                        str.push($(this).val());
                    });
                    param = str.join(',');
                }

                if (url != undefined && url != '') {
                    window.location.href = url + '/ids/' + param;
                }
            });

            //回車自動提交
            $('.search-form').find('input').keyup(function (event) {
                if (event.keyCode === 13) {
                    $("#search").click();
                }
            });

            $('#time-start').datetimepicker({
                format: 'yyyy-mm-dd',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });

            $('#time-end').datetimepicker({
                format: 'yyyy-mm-dd',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });
        })
    </script>
</block>